package com.cswangdao.mapper;

import com.cswangdao.domain.dto.CouponPageDTO;
import com.cswangdao.domain.model.MarketCoupon;
import com.cswangdao.domain.po.Coupon;
import com.cswangdao.domain.vo.AvailableCouponVo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MarketCouponMapper {

    /**
     * @description: 优惠卷分页查询
     * @param: couponPageDTO
     * @return: Page<Coupon>
     */
    Page<Coupon> pageQueryInfo(CouponPageDTO couponPageDTO);

    /**
     * @description: 新增优惠卷
     * @param: coupon
     * @return: void
     */
    void insert(Coupon coupon);

    /**
     * @description: 根据Id查询优惠卷
     * @param: id
     * @return: Coupon
     */
    Coupon selectById(@Param("id") Integer id);

    void updateById(Coupon coupon);

    @Delete("delete from market_coupon where id = #{id}")
    void deleteById(Integer id);

    Coupon queryById(int i);

    List<MarketCoupon> getAll(@Param("limit") Integer limit);

    List<Integer> getAllCouponIds();

    List<MarketCoupon> getByIds(@Param("couponIds") List<Integer> couponIds, @Param("limit") Integer limit);

    MarketCoupon getById(Integer couponId);

    @Update("update market_coupon set total = #{total} WHERE id = #{couponId}")
    void reduceTotal(@Param("couponId") Integer couponId, @Param("total") int total);

    Page<MarketCoupon> getMyCoupons(@Param("couponIds") List<Integer> couponIds);

    List<AvailableCouponVo> getAvailableCouponsByIds(@Param("couponIds") List<Integer> couponIds);

    MarketCoupon getCouponByCode(@Param("code") String code);

    Page<MarketCoupon> selectAll(@Param("status") short status);
}